calculating the multiplicative inverse